<template>
  <div>
    <button @click="getStudents">获取学生信息</button>
    <button @click="getCars">获取汽车信息</button>
  </div>
</template>

<script>
  import axios from 'axios'

  export default {
    name: "App",
    methods: {
      getStudents() {
        // 访问本地资源 并不经过代理
        // axios.get('http://localhost:8081/test.txt').then(
        // axios.get('http://localhost:8081/students').then(
        axios.get('http://localhost:8081/atguigu/students').then(  
          response => {
            console.log("请求成功了", response.data)
          },
          error => {
            console.log("请求失败了", error)
          }
        )
      },
      getCars() {
        axios.get('http://localhost:8081/demo/cars').then(  
          response => {
            console.log("请求成功了", response.data)
          },
          error => {
            console.log("请求失败了", error)
          }
        )
      }
    }
  };
</script>

<style>
  
</style>